//Practical3D
//Lesson 1. Drawing

/**
Draw points
The camera and material is already taken care of
*/
virtual void render()
{
	renderer->clear();

	vec3 points[4] = {vec3(0,0,0), vec(0,1,0), vec(1,1,0), vec(1,0,0) };
	
	renderer->bindCoords(points);
	renderer->draw(Renderer::Points, 4); //num points
}

/**
Draw continuous line
Show how points merge together into a continuous line
*/
virtual void render()
{
	renderer->clear();

	vec3 points[4] = {vec3(0,0,0), vec(0,1,0), vec(1,1,0), vec(1,0,0), vec(0,0,0) };
	
	renderer->bindCoords(points);
	renderer->draw(Renderer::LineStrip, 5); //num points
}}

/**
Draw segments
Show how points can be used to draw isolate segments
*/
virtual void render()
{
	renderer->clear();

	vec3 points[4] = {vec3(0,0,0), vec(0,1,0), vec(1,1,0), vec(1,0,0) };
	
	renderer->bindCoords(points);
	renderer->draw(Renderer::LineList, 4); //num points
}}

/**
Draw 10x10 grid
Show how points can be used to draw isolate segments
*/
vec3 points[11*2*2];//22 lines, 2 points each

virtual void open()
{
	for (int x = 0; x <= 10; x++) {
		points.push_back(vec3(x, 0, 0));
		points.push_back(vec3(x, 10, 0));
	}
	
	for (int y= 0; y <= 10; y++) {
		points.push_back(vec3(0, y, 0));
		points.push_back(vec3(10, y, 0));
	}
}

virtual void render()
{
	renderer->clear();

	renderer->bindCoords(points.data());
	renderer->draw(Renderer::LineList, 4); //num points
}

/**
A starfield
Show how points can be animated to simulate moving stars
*/
struct Star {
	vec3 pos;
	float speed;
	float size;
};
const int NUM_STARS = 100;
Star stars[NUM_STARS];
vec3 coords[NUM_STARS];

virtual void update()
{
	//animate the starfield
}

virtual void render()
{
	for (int i=0; i<NUM_STARS; i++)
	{
		coords[i] = stars[i].pos;
	}
	
	renderer->bindCoords(coords);
	renderer->draw(Renderer::Points, NUM_STARS);
}
